Skip to content

Conversation

blakeembrey
Copy link
Member

Closes #336, #358, #356, and #354.

Adds originalPath to TokenData, which will be used (when available) for the error messages. It's already added to any methods that input a string.

@blakeembrey blakeembrey requested a review from a team May 10, 2025 18:02
@blakeembrey blakeembrey force-pushed the be/debug-original-path branch from b25a26b to 3f25805 Compare May 10, 2025 18:03
Copy link
Member

@bjohansebas bjohansebas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Member

@UlisesGascon UlisesGascon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@bjohansebas
Copy link
Member

Can we move forward and make a release for this? this really helps a lot with migrating from Express 4 to Express 5

@shivarm
Copy link

shivarm commented Jul 31, 2025

I think it is time to land it with new realease

Copy link

codecov bot commented Jul 31, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.21%. Comparing base (26d87a2) to head (85e5e2c).
⚠️ Report is 27 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##            master     #363      +/-   ##
===========================================
- Coverage   100.00%   99.21%   -0.79%     
===========================================
  Files            1        1              
  Lines          668      381     -287     
  Branches       151      132      -19     
===========================================
- Hits           668      378     -290     
- Misses           0        3       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blakeembrey
Copy link
Member Author

Refactored and added a test to reduce stack size for pillarjs/router#158.

Copy link
Member

@bjohansebas bjohansebas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, for posterity, why did you stop using generators?

@blakeembrey
Copy link
Member Author

why did you stop using generators?

Easiest way reduce the error stack size, otherwise it has 2-3 lines per generator.

function* lexer(str: string): Generator<LexToken, LexToken> {
function errorMessage(text: string, originalPath: string | undefined) {
let message = text;
if (originalPath !== undefined) message += `: ${originalPath}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have actually been meaning to ask if we could get the individual things on the error instance as properties, so this PR feel like a great time to mention that. It would help for o11y to have them that way as well as in the message.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just the path or something else too? I can add it in a new PR.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to skip for now. I forgot why I didn't do this originally but turning this into the error object instead of the message adds an extra line to the error stack which is additional obfuscation of the source (one complaint in the issue I'm trying to resolve).

Adding it to every error in the source code increases the package size by 1%. I don't think it's currently worth it since no one has asked for it, but if you feel strongly I can open the change still.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opened a PR here #398.

Found a way to minimize the size increase a bit more by using an error sub-class. Since the package is ES2015+ that should work everywhere I support. Using the custom class does not add to the stack size in node at least.

@blakeembrey blakeembrey merged commit a6bdf40 into master Aug 18, 2025
7 of 8 checks passed
@blakeembrey blakeembrey deleted the be/debug-original-path branch August 18, 2025 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error message when parsing fails
5 participants